package com.filetransfer.utils;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class SystemUtils {
    public static void showFileInFolder(String filePath) {
        //windows
        if (System.getProperty("os.name").toLowerCase().contains("windows")) {
            showFileInFolderForWindows(filePath);
        } else {
            //linux
            showFileInFolderForLinux(filePath);
        }
    }
    private static void showFileInFolderForLinux(String filePath) {
        // todo
    }
    private static void showFileInFolderForWindows(String filePath) {
        // 使用文件资源管理器选中
        try {
            Runtime.getRuntime().exec("explorer.exe /select,\"" + filePath
                    .replace("/", "\\")
                    + "\"");
        } catch (Exception e) {
            log.error("打开文件夹失败", e);
        }
    }
}
